﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace d39
{
    // Returns doubled numbers, so what would parse as "1" in Base26 is returned as "2" in Base26.5.
    // A prefix of 5 indicates ".5", eg 5a translates to 1.5 which is returned as 3.
    public static class Base26Point5
    {
        public static int ParseDoubleInt(string str, int start, out int end)
        {
            var point5 = 0;
            if (str[start] == '5')
            {
                point5 = 1;
                start++;
            }
            return Base26.ParseInt(str, start, out end) * 2 + point5;
        }
        public static string DoubleIntToString(int n)
        {
            return (n % 2 == 0 ? "" : "5") + Base26.IntToString(n / 2);
        }
        public static bool IsValidChar(string str, int start)
        {
            return start < str.Length && (str[start] == '5' || Base26.IsValidChar(str, start));
        }
    }
}